#ifndef QFRAMELESSDIALOG_H
#define QFRAMELESSDIALOG_H

#include <QDialog>

class QFramelessDialog : public QDialog
{
	Q_OBJECT

public:
	QFramelessDialog(QWidget *parent);
	~QFramelessDialog();

	void Init(QWidget *widget_title, 
			  QPushButton *menuButton_Close, 
			  QPushButton *menuButton_Max,
			  QPushButton *menuButton_Min,
			  bool bResize,
			  bool bMinClose,
			  bool bConnectClose);

	void setResizeable(bool resizeable);
	virtual void CloseDialog();
private:
	bool m_bMaximized;
	bool m_bMoveable;
	QPoint dragPosition;
	QRect m_rcNormal;

protected:
	void mouseMoveEvent(QMouseEvent *e);
	void mousePressEvent(QMouseEvent *e);
	void mouseReleaseEvent(QMouseEvent *);
	void mouseDoubleClickEvent(QMouseEvent *event);

	bool nativeEvent(const QByteArray & eventType, void * message, long * result);

	void paintEvent(QPaintEvent *event);

	void keyPressEvent(QKeyEvent* e);

public slots:
/*	void sltCloseClick();*/
	void sltClickMin();
	void sltClickMaxRestore();
	void sltCloseDialog();

public:
	bool m_bResize;
	QPushButton *m_menuButton_Close;
	QPushButton *m_menuButton_Max;
	QPushButton *m_menuButton_Min;
	QWidget *m_widget_title;
	bool m_bMinClose;
	bool m_bConnectClose;
};

#define FRAMELESS_DIALOG_INIT() Init(ui.widget_title, ui.menuButton_Close, nullptr, nullptr, false, false, true)
#define FRAMELESS_MAIN_DIALOG_INIT() Init(ui.widget_title, ui.menuButton_Close, ui.menuButton_Max, ui.menuButton_Min, true, true, true)
#define FRAMELESS_MAIN_DIALOG_NOCLOSE_INIT() Init(ui.widget_title, ui.menuButton_Close, ui.menuButton_Max, ui.menuButton_Min, true, true, false)

#define FRAMELESS_DIALOG_INIT2() Init(ui->widget_title, ui->menuButton_Close, nullptr, nullptr, false, false, true)
#define FRAMELESS_MAIN_DIALOG_INIT2() Init(ui->widget_title, ui->menuButton_Close, ui->menuButton_Max, ui->menuButton_Min, true, true, true)
#define FRAMELESS_MAIN_DIALOG_NOCLOSE_INIT2() Init(ui->widget_title, ui->menuButton_Close, ui->menuButton_Max, ui->menuButton_Min, true, true, false)




#endif // QFRAMELESSDIALOG_H
